import axios from '../axios';
import * as Types from './project.d';
import { LoginRes } from '@/api/user/user.d';

const preFix = '';
export function getTableData(data: Types.SeachData) {
  return axios.post<Types.CommonTableRes<Types.TableListItem>>(
    '/anno/task/search',
    data
  );
}

export function changeStatus(data: Types.StatusParams) {
  return axios.post<Types.CommonRes<null>>('/anno/task/status/edit', data);
}

export function copyTableItem(data: Types.CopyParams) {
  return axios.post<Types.CommonRes<null>>('/anno/task/copy', data);
}

export const getCommonConfig = (data: Types.CommonConfigParams) => {
  return axios.post<Types.CommonConfigResponse>(
    preFix + '/config/common/list',
    data
  );
};

export const getToolConfig = (data: Types.ToolConfigParams) => {
  return axios.post<Types.CommonTableRes<Types.ToolConfigItem>>(
    preFix + '/config/tool/search',
    data
  );
};

export const getComponentConfig = (data: Types.CompConfigParams) => {
  return axios.post<Types.CommonTableRes<Types.CompConfigItem>>(
    preFix + '/config/component/search',
    data
  );
};

export const getLesionConfig = (data: Types.ToolConfigParams) => {
  return axios.post<Types.CommonTableRes<Types.LesionConfigItem>>(
    preFix + '/config/lesion/group/search',
    data
  );
};

export const getCompanyConfig = (data: Types.CompanyConfigParams) => {
  return axios.post<Types.CompanyConfigItem[]>(preFix + '/company/list', data);
};

export const getProjectDetail = (id: number) => {
  return axios.get(preFix + '/anno/task/' + id);
};

export const existedProjectName = (data: Types.ExistedProjectNameParams) => {
  return axios.post<Types.ExistedProjectNameResponse>(
    preFix + '/anno/task/name/existed',
    data
  );
};
//创建任务
export const saveTaskData = (data: Types.SaveDataParams) => {
  return axios.post<Types.SaveDataResponse>(preFix + '/anno/task', data);
};
//编辑任务
export const updateTaskData = (data: Types.SaveDataParams) => {
  return axios.put<Types.SaveDataResponse>(preFix + '/anno/task', data);
};

export const videoPreprocess = (data) => {
  return axios.post<Types.VideoPreprocessResponse>(
    preFix + '/image/transfer/result/query',
    data
  );
};

export const getUserData = (data: Types.GetUserDataParams) => {
  return axios.post<Types.CommonTableRes<LoginRes>>(
    preFix + '/user/search',
    data
  );
};
//标注结果导入
export const importAnnoData = (data: any) => {
  return axios.post<any>(
      '/anno/result/import',
      data
  );
};
//标注结果导入记录
export const getImportAnnoData = (data: any) => {
  return axios.post<any>('/anno/result/import/log/list', data);
};
